package fr.liglab.adele.icasa.app;

import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Invalidate;
import org.apache.felix.ipojo.annotations.Requires;
import org.apache.felix.ipojo.annotations.Validate;

import fr.liglab.adele.icasa.device.temperature.Thermometer;
import fr.liglab.adele.icasa.environment.SimulatedEnvironmentManager;


@Component
public class ThermoHeaterTest extends Thread {

	//@Requires
	//SimulatedEnvironment simEnv;
	
	@Requires
	Thermometer thermometer;

	boolean work;
	
	@Override
	public void run(){
		while(work){
			System.out.println("Temperature: "+ thermometer.getTemperature());
			
			try {
				Thread.sleep(2000);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
	}
	
	@Validate
	 public void starting() {         
	    work=true;
	    this.start();//starts the thread
	 }

	 @Invalidate
	 public void stopping() {    
		work=false;
	 }

}
